home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 2: CDPD 1 / Almathera Ten on Ten - Disc 2: CDPD 1.iso / pd / 576-600 / 592 / star / star.h < prev    next >
C/C++ Source or Header  |  1995-03-15  |  872b  |  67 lines

  1.  
  2. #include <math.h>
  3. #include <exec/memory.h>
  4.  
  5.  
  6.  
  7. void Free_Values(int *p)
  8. {
  9. int points;
  10.  
  11. points=p[0];
  12. FreeMem(p,(points*2+2)*sizeof(int *));
  13.  
  14. return;
  15. }
  16.  
  17. int Draw_Star(struct RastPort *rastport,int *p,int x,int y,int count)
  18. {
  19. int x1,y1,points,w;
  20.  
  21. if(p==NULL) return(0);
  22.  
  23. x1=x-160;
  24. y1=y-128;
  25.  
  26. points=p[0];
  27.  
  28. count=count%points;
  29.  
  30. w=count;
  31. Move(rastport,p[1]+x1,p[points+1]+y1);
  32. Draw(rastport,p[1+w]+x1,p[points+1+w]+y1);
  33.    while(w)
  34.    {
  35.    w+=count;
  36.    w=w%points;
  37.    Draw(rastport,p[1+w]+x1,p[1+points+w]+y1);
  38.    }
  39.  
  40. return(1);
  41. }
  42.  
  43.  
  44.  
  45. int *Init_Values(int radius,int points)
  46. {
  47.  
  48. int n,*p;
  49. float incr;
  50.  
  51. p=(int *)AllocMem(sizeof(int *)*(points*2+2),MEMF_PUBLIC+MEMF_CLEAR);
  52. if(p==NULL) return(0);
  53.  
  54. p[0]=points;
  55.  
  56. incr=2.0*3.141592654/points;
  57.  
  58. for(n=1;n<=points;n++)
  59.    {
  60.    p[n]=floor(radius*cos(n*incr)+160);
  61.    p[n+points]=floor(radius*sin(n*incr)+128);
  62.    }
  63.  
  64. return((int *)p);
  65. }
  66.  
  67.